using Assets.Scripts.GDK;
using UnityEngine;

namespace Brick
{
	public class GameCtolBox : gdk_base_UI
	{
		public Transform menuBox;

		public Transform sliderBox;

		public Transform downBox;

		public Transform dangerBgBox;

		public Transform enmeyBox;

		public Transform qucikBox;

		public override void OnLoad()
		{
			gdk_game_manager.AddEventListener(EventID.SHOW_PLAY_MENU, showMenu);
			gdk_game_manager.AddEventListener(EventID.SHOW_PLAY_SLIDER, showSlider);
			gdk_game_manager.AddEventListener(EventID.SHOW_PLAY_RECORD, showDown);
			gdk_game_manager.AddEventListener(EventID.HIDE_PLAY_MENU, hideMenu);
			gdk_game_manager.AddEventListener(EventID.SHOW_PLAY_DANGER, showDangerBg);
			gdk_game_manager.AddEventListener(EventID.HIDE_PLAY_DANGER, hideDangerBg);
			gdk_game_manager.AddEventListener<int>(EventID.GAME_PLAY_START, showEnemy);
			gdk_game_manager.AddEventListener(EventID.GAME_OVER_DAOJU, OnGameOverDaoju);
			gdk_game_manager.AddEventListener(EventID.GAME_OVER_END, OnGameOverEnd);
			gdk_game_manager.AddEventListener(EventID.GAME_WIN, OnGameWin);
			gdk_game_manager.AddEventListener<int>(EventID.GAME_QUICKBG, OnQuick);
		}

		public override void UnLoad()
		{
			gdk_game_manager.RemoveEventListener(EventID.SHOW_PLAY_MENU, showMenu);
			gdk_game_manager.RemoveEventListener(EventID.SHOW_PLAY_SLIDER, showSlider);
			gdk_game_manager.RemoveEventListener(EventID.SHOW_PLAY_RECORD, showDown);
			gdk_game_manager.RemoveEventListener(EventID.HIDE_PLAY_MENU, hideMenu);
			gdk_game_manager.RemoveEventListener(EventID.SHOW_PLAY_DANGER, showDangerBg);
			gdk_game_manager.RemoveEventListener(EventID.HIDE_PLAY_DANGER, hideDangerBg);
			gdk_game_manager.RemoveEventListener<int>(EventID.GAME_PLAY_START, showEnemy);
			gdk_game_manager.RemoveEventListener(EventID.GAME_OVER_DAOJU, OnGameOverDaoju);
			gdk_game_manager.RemoveEventListener(EventID.GAME_OVER_END, OnGameOverEnd);
			gdk_game_manager.RemoveEventListener(EventID.GAME_WIN, OnGameWin);
			gdk_game_manager.RemoveEventListener<int>(EventID.GAME_QUICKBG, OnQuick);
		}

		public override void OnStart()
		{
			hideDown();
			hideMenu();
			hideSlider();
			hideDangerBg();
			hideQuick();
		}

		private void showMenu()
		{
			menuBox.GetComponent<MenuBox>().onShowEvent();
			hideSlider();
			hideDown();
		}

		private void hideMenu()
		{
			menuBox.GetComponent<MenuBox>().onHideEvent();
		}

		private void showSlider()
		{
			sliderBox.GetComponent<SliderBox>().onShowEvent();
			hideMenu();
			hideDown();
		}

		private void hideSlider()
		{
			sliderBox.GetComponent<SliderBox>().onHideEvent();
		}

		private void showDown()
		{
			downBox.GetComponent<DownBox>().onShowEvent();
			hideSlider();
			hideMenu();
		}

		private void hideDown()
		{
			downBox.GetComponent<DownBox>().onHideEvent();
		}

		private void showDangerBg()
		{
			dangerBgBox.GetComponent<DangerBox>().onShowEvent();
		}

		private void hideDangerBg()
		{
			dangerBgBox.GetComponent<DangerBox>().onHideEvent();
		}

		private void showEnemy(int index)
		{
			enmeyBox.GetComponent<EnemyBox>().onShowEvent(index);
		}

		private void hideEnemy()
		{
			enmeyBox.GetComponent<EnemyBox>().onHideEvent();
		}

		private void OnQuick(int showIndex)
		{
			switch (showIndex)
			{
				case 1:
					showQuick();
					break;
				case 2:
					hideQuick();
					break;
			}
		}

		private void showQuick()
		{
			qucikBox.GetComponent<QuickPanel>().onShowEvent();
		}

		private void hideQuick()
		{
			qucikBox.GetComponent<QuickPanel>().onHideEvent();
		}

		private void OnGameOverDaoju()
		{
			gdk_game_manager.showPanel(PanelID.USEDAOJU);
		}

		private void OnGameOverEnd()
		{
			gdk_game_manager.showPanel(PanelID.GAMEEND);
		}

		private void OnGameWin()
		{
			gdk_game_manager.showPanel(PanelID.GAMEPASS);
		}
	}
}

